<?php
namespace App\Noxinfluencer\Controllers;

require_once '../../../vendor/autoload.php';

use phpspider\core\phpspider;
use phpspider\core\requests;
use phpspider\core\selector;

/* Do NOT delete this comment */
/* 不要删除这段注释 */


$url = "https://cn.noxinfluencer.com/youtube/channel/UC6dpG6lhE3kyP0S2zHyxamg";
$html = requests::get($url);

file_put_contents('./nox_about.html',$html);

// 选择器规则
$selector = "//a[@class='star-name']";  //kol名
$name = selector::select($html, $selector);

$selector = "//span[@class='num']";  //总书记
$nums = selector::select($html, $selector);

$selector = "//div[@class='info-bottom']//span[@class='strong']";  //粉丝量
$fans_nums = selector::select($html, $selector);

$selector = "//ul[@class='data-list kol-data']/li[@class='data-item'][1]/span[@class='num']";  //视频数量
$video_nums = selector::select($html, $selector);

$selector = "//ul[@class='data-list kol-data']/li[@class='data-item'][last()]/span[@class='num']";  //浏览量
$view_count = selector::select($html, $selector);

$selector = "//p[@class='kol-des']";  //kol描述
$description = selector::select($html, $selector);

$selector = "//a[@class='star-name']/@href";  //channel_id
$channel_id = selector::select($html, $selector);

$selector = "//div[@class='data-tooltip-img']/img/@src";  //头像
$head_img = selector::select($html, $selector);

$selector = "//div[@class='info-content']//span[@class='subtitle underline']";
$country = selector::select($html, $selector);

$data = array(
    'name' => $name,
    'nums'=> $nums,
    'video_nums'=>$video_nums,
    'fans_nums' => $fans_nums,
    'view_count' => $view_count,
    'description' => $description,
    'country' => $country,
    'channel' => $channel_id,
    'head_img'=>$head_img,
);

// 查看数据是否正常
print_r($data);


file_put_contents('./test.txt',preg_replace("/(\s|\ \;| |\xc2\xa0)/","",$country));





